package com.bestcem.xm.award.entity.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.bestcem.xm.award.enums.*;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Transient;

import java.util.Date;
import java.util.Map;

/**
 * 用户请求奖励记录表
 *
 * @author sh.pei <sh.pei@idiaoyan.com>
 * @version v1.0
 * @date 2021/6/28 10:45
 */
@ToString(callSuper = true)
@Getter
@Setter
public class AwardRequestDO {

    /**
     * 主键
     */
    private String id;

    /**
     * 奖励id
     */
    private String awardId;

    /**
     * 请求ip
     */
    private String ip;

    /**
     * 奖励检查结果 {@link AwardRequestStatusEnum}
     */
    private Integer status;

    /**
     * 请求设备 {@link DeviceTypeEnum}
     */
    private Integer tty;

    /**
     * 投放相关信息
     */
    private Map<String, Object> deliver;

    /**
     * 投放相关信息DTO，不入库
     */
    @Transient
    private Deliver deliverDTO;

    /**
     * 答卷相关信息
     */
    private Survey survey;

    @JsonProperty("create_time")
    private Date createdDate;

    @JsonProperty("update_time")
    private Date updatedDate;

    @Data
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class Deliver {

        /**
         * 投放来源 {@link DeliverSourceEnum}
         */
        @JSONField(name = "source")
        private Integer source;

        /**
         * 编号
         */
        @JSONField(name = "code")
        private String code;

        /**
         * 场景 {@link DeliverSceneEnum}
         */
        @JSONField(name = "scenes")
        private Integer scenes;

        /**
         * 组织编号
         */
        @JSONField(name = "org_code")
        private String orgCode;

        /**
         * 投放id
         */
        @JSONField(name = "deliver_id")
        private String deliverId;

        /**
         * 签名
         */
        @JSONField(name = "sig")
        private String sig;

        /**
         * 是否开启重复提交问卷
         */
        @JSONField(name = "checkSubmit")
        private String checkSubmit;

        /**
         * 校验编号
         */
        @JSONField(name = "checkCode")
        private String checkCode;

        /**
         * 会员id
         */
        @JSONField(name = "memberId")
        private String memberId;

        /**
         * 奖励id
         */
        @JSONField(name = "awardId")
        private String awardId;
    }


    @Data
    public static class Survey {

        /**
         * 问卷id
         */
        @JSONField(name = "survey_id")
        private String surveyId;

        /**
         * 答卷唯一标识
         */
        @JSONField(name = "seq")
        private Long seq;

        /**
         * 答卷状态 {@link SurveyStatusEnum}
         */
        @JSONField(name = "status")
        private Integer status;

        /**
         * 答卷来源 {@link DeliverSourceEnum}
         */
        @JSONField(name = "source")
        private Integer source;

        /**
         * 答题ip
         */
        @JSONField(name = "survey_ip")
        private String surveyIp;

        /**
         * 发出请求的时间戳
         */
        @JSONField(name = "ts")
        private Long ts;

        /**
         * 投放id
         */
        @JSONField(name = "deliver_id")
        private String deliverId;

        /**
         * 答题花费时间
         */
        @JSONField(name = "timecost")
        private Integer costTime;

        /**
         * 签名
         */
        private String sig;
    }
}
